package no.ntnu.fp.handlers;

import no.ntnu.fp.handler.Handler;
import no.ntnu.fp.messages.Message;
import no.ntnu.fp.messages.impl.AppointmentAddedOrUpdatedMessage;
import no.ntnu.fp.model.Appointment;
import no.ntnu.fp.model.CalendarModel;

public class AppointmentAddedOrUpdatedHandler implements Handler {

	private final CalendarModel calendarModel;
	
	public AppointmentAddedOrUpdatedHandler(CalendarModel calendarModel) {
		this.calendarModel = calendarModel;
	}

	@Override
	public void handleMessage(Message message) {
		AppointmentAddedOrUpdatedMessage appointmentAddedMessage = (AppointmentAddedOrUpdatedMessage) message;
		Appointment appointment = appointmentAddedMessage.getAppointment();
		calendarModel.addOrUpdateAppointment(appointment.getEmployee(), appointment);
	}
}
